package com.jevons.geo_lib.geo_op;

import com.jevons.geo_lib.op_history.DrawType;
import com.mapbox.geojson.Feature;

import java.util.HashSet;
import java.util.List;
import java.util.Set;


/**
 * Copyright 2020 JxGIS
 *
 * @file GeoSubmitResult
 * @auth linaisheng
 * Created on 2023/12/29.
 * Description：
 */
public class GeoSubmitResult {

    DrawType drawType;

    Feature editSourceFeature;

    List<Feature> resultFeatures;

    List<GeoOpSaveResult> opSaveResults;

    GeoSubmitResult(
            DrawType drawType,
            Feature editSourceFeature,
            List<Feature> resultFeatures,
            List<GeoOpSaveResult> opSaveResults) {
        this.drawType = drawType;
        this.editSourceFeature = editSourceFeature;
        this.resultFeatures = resultFeatures;
        this.opSaveResults = opSaveResults;
    }

    public DrawType getDrawType() {
        return drawType;
    }

    public Feature getEditSourceFeature() {
        return editSourceFeature;
    }

    public String getSelectedEditFeatureId() {
        if (editSourceFeature != null) {
            return editSourceFeature.getStringProperty(GeometryOpManager.KEY_FEATURE_ID);
        }
        return null;
    }

    public List<Feature> getResultFeatures() {
        return resultFeatures;
    }

    public Set<String> getRemoveEditIds() {
        HashSet<String> deleteIds = new HashSet<>();
        if (opSaveResults != null && opSaveResults.size() > 0) {
            for (GeoOpSaveResult saveResult : opSaveResults) {
                deleteIds.addAll(saveResult.deleteFeatureIds);
            }
        }
        return deleteIds;
    }

    public List<GeoOpSaveResult> getOpSaveResults() {
        return opSaveResults;
    }

}